package org.mch.func.file.bijiao;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

import org.mch.biz.ui.FuncEvent;
import org.mch.biz.ui.FuncPanel;
import org.mch.swingm.core.MCompanyLogoListCellRenderer;
import org.mch.swingm.ext.METextChooser;

public class ClientPanel extends FuncPanel {
	private static final long serialVersionUID = 6739176691110502567L;

	private JSplitPane splitPane;
	private JPanel panel_up;
	private JPanel panel_down;
	private JScrollPane scrollPane;
	private JList<String> list_file;
	private METextChooser text_folder;
	private JLabel label_1;
	private JTextField text_sepsplit;
	private JLabel label_2;
	private JTextField text_sepnumber;
	private JLabel label_3;
	private JButton btn_execute;
	private JButton btn_delfile;

	public ClientPanel() {
		super();
		initGUI();
	}

	private void initGUI() {
		setLayout(new BorderLayout(0, 0));
		add(getSplitPane(), BorderLayout.CENTER);
	}

	public JSplitPane getSplitPane() {
		if (splitPane == null) {
			splitPane = new JSplitPane();
			splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
			splitPane.setLeftComponent(getPanel_up());
			splitPane.setRightComponent(getPanel_down());
			splitPane.setDividerLocation(200);
		}
		return splitPane;
	}

	public JPanel getPanel_up() {
		if (panel_up == null) {
			panel_up = new JPanel();
			panel_up.setLayout(null);
			panel_up.add(getText_folder());
			panel_up.add(getLabel_1());
			panel_up.add(getText_sepsplit());
			panel_up.add(getLabel_2());
			panel_up.add(getText_sepnumber());
			panel_up.add(getLabel_3());
			panel_up.add(getBtn_execute());
			panel_up.add(getBtn_delfile());
		}
		return panel_up;
	}

	public JPanel getPanel_down() {
		if (panel_down == null) {
			panel_down = new JPanel();
			panel_down.setLayout(new BorderLayout(0, 0));
			panel_down.add(getScrollPane(), BorderLayout.CENTER);
		}
		return panel_down;
	}

	public JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBorder(new TitledBorder(null, "\u6587\u4EF6\u5217\u8868", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			scrollPane.setViewportView(getList_file());
		}
		return scrollPane;
	}

	public JList<String> getList_file() {
		if (list_file == null) {
			list_file = new JList<String>();
			list_file.setCellRenderer(new MCompanyLogoListCellRenderer<Object>());
			list_file.setBorder(new LineBorder(new Color(0, 0, 0)));
		}
		return list_file;
	}

	public METextChooser getText_folder() {
		if (text_folder == null) {
			text_folder = new METextChooser("目录：",METextChooser.SELECT_FOLDER);
			text_folder.setBounds(10, 7, 552, 33);
		}
		return text_folder;
	}

	@Override
	protected FuncEvent createEvent() {
		return new ClientEvent(this);
	}

	public JLabel getLabel_1() {
		if (label_1 == null) {
			label_1 = new JLabel("\u6309\u5B57\u7B26\uFF1A");
			label_1.setBounds(10, 53, 61, 15);
		}
		return label_1;
	}

	public JTextField getText_sepsplit() {
		if (text_sepsplit == null) {
			text_sepsplit = new JTextField();
			text_sepsplit.setHorizontalAlignment(SwingConstants.CENTER);
			text_sepsplit.setFont(new Font("����", Font.BOLD, 12));
			text_sepsplit.setText("_");
			text_sepsplit.setBounds(73, 50, 37, 21);
			text_sepsplit.setColumns(10);
		}
		return text_sepsplit;
	}

	public JLabel getLabel_2() {
		if (label_2 == null) {
			label_2 = new JLabel(
					"\u4E4B\u524D\u7684\u6587\u4EF6\u540D\u6216\u76EE\u5F55\u8FDB\u884C\u6BD4\u8F83\uFF1B\u5982\u6709\u591A\u4E2A\u6309\u7B2C\uFF1A");
			label_2.setBounds(120, 53, 258, 15);
		}
		return label_2;
	}

	public JTextField getText_sepnumber() {
		if (text_sepnumber == null) {
			text_sepnumber = new JTextField();
			text_sepnumber.setHorizontalAlignment(SwingConstants.CENTER);
			text_sepnumber.setFont(new Font("����", Font.BOLD, 12));
			text_sepnumber.setText("2");
			text_sepnumber.setBounds(374, 50, 37, 21);
			text_sepnumber.setColumns(10);
		}
		return text_sepnumber;
	}

	public JLabel getLabel_3() {
		if (label_3 == null) {
			label_3 = new JLabel("\u4E2A\uFF1B");
			label_3.setBounds(421, 53, 54, 15);
		}
		return label_3;
	}

	public JButton getBtn_execute() {
		if (btn_execute == null) {
			btn_execute = new JButton("\u6267\u884C");
			btn_execute.setBounds(10, 166, 75, 23);
			btn_execute.addActionListener(getEvent());
		}
		return btn_execute;
	}

	public JButton getBtn_delfile() {
		if (btn_delfile == null) {
			btn_delfile = new JButton("\u5220\u9664");
			btn_delfile.setBounds(84, 166, 75, 23);
			btn_delfile.addActionListener(getEvent());
		}
		return btn_delfile;
	}
}
